﻿<?php
require_once "common.php";
//获得栏目id
$pid=$_GET[pid];
//var_dump($pid);
if($pid!=''){
	$part=new part($pid,'','');
	$pname=$part->selectPart();
}

?>
<form action="./part_edit.php" method="POST">
栏目名：	<input type="text" name="part" value="<?php echo $pname[part];?>"/><br />
是否顶级栏目：	<input type="radio" name="top" value="1"<?php if($pname[top]==1){echo "checked";}?>/>是&nbsp
				<input type="radio" name="top" value="0"<?php if($pname[top]==0){echo "checked";}?>/>否<br />
				<input type="hidden" name="pid" value="<?php echo $pname[pid];?>" />
			<input type="submit" value="保存"/>
</form>
<?php
//将新数据提交并写入数据库
$pid=$_POST[pid];
$newPart=$_POST[part];
$newTop=$_POST[top];
//分两次写入，是否可修改？
if($newPart!=''){
	$part=new part($pid,'','');
	$res_p=$part->editPart(part,$newPart);
	}
if($newTop!=''){
	$part=new part($pid,'','');
	$res_t=$part->editPart(top,$newTop);
	}
//添加适当的操作提示，优化操作
if($res_t&&$res_p){
	echo "修改栏目成功！";
	$redirector=new redirector('./part_list.php',3,'栏目修改成功！');
	$redirector->redirect();
	//echo "<script>location.href='./part_list.php'</script>";
	//echo $pid;
	//echo $part;
	//echo $top;
}
?>